using System.ComponentModel.DataAnnotations;

namespace MonitorPlatform.Data.Entities
{
    public class AlertHistory : BaseEntity
    {
        [Key]
        public Guid AlertId { get; set; } = Guid.NewGuid();

        [Required]
        [StringLength(50)]
        public string AppId { get; set; } = string.Empty;

        [Required]
        public Guid RuleId { get; set; }

        public DateTime AlertTime { get; set; }

        [StringLength(500)]
        public string? AlertTitle { get; set; }

        public string AlertMessage { get; set; } = string.Empty;

        public string Severity { get; set; } = "Medium";

        [StringLength(20)]
        public string? Status { get; set; } = "Active"; // Active, Acknowledged, Resolved, Closed

        // Alert Data (JSON)
        public string? AlertData { get; set; }

        // Metric Values at Alert Time
        public double? MetricValue { get; set; }
        public double? ThresholdValue { get; set; }

        // Resolution Information
        public DateTime? AcknowledgedAt { get; set; }

        [StringLength(100)]
        public string? AcknowledgedBy { get; set; }

        public string? AcknowledgmentNotes { get; set; }

        public DateTime? ResolvedAt { get; set; }

        [StringLength(100)]
        public string? ResolvedBy { get; set; }

        public string? ResolutionNotes { get; set; }

        // Notification Status
        public bool EmailSent { get; set; } = false;
        public bool WebhookSent { get; set; } = false;
        public bool SmsSent { get; set; } = false;

        public DateTime? EmailSentAt { get; set; }
        public DateTime? WebhookSentAt { get; set; }
        public DateTime? SmsSentAt { get; set; }

        // Failure Information
        public string? EmailError { get; set; }
        public string? WebhookError { get; set; }
        public string? SmsError { get; set; }

        // Additional Context
        public string? AdditionalContext { get; set; }

        // Navigation properties
        public virtual AlertRule AlertRule { get; set; } = null!;
    }
} 